/*
 * @lc app=leetcode.cn id=896 lang=javascript
 *
 * [896] 单调数列
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {boolean}
 */
var isMonotonic = function (nums) {
  if (nums.length < 3) return true;
  let a = true, b = true;
  for (let i = 1; i < nums.length; i++) {
    if (nums[i] < nums[i - 1]) a = false;
    if (nums[i] > nums[i - 1]) b = false;
  }
  return a || b;
};
// @lc code=end

